/*
 * @Author: t-xiangqun.li t-xiangqun.li@pcitc.com
 * @Date: 2025-09-08 16:54:41
 * @LastEditors: lixiangqun
 * @LastEditTime: 2025-11-06 15:05:36
 * @FilePath: \electrconVue\src\renderer.ts
 * @Description: 渲染进程
/**
 * This file will automatically be loaded by vite and run in the "renderer" context.
 * To learn more about the differences between the "main" and the "renderer" context in
 * Electron, visit:
 *
 * https://electronjs.org/docs/tutorial/process-model
 *
 * By default, Node.js integration in this file is disabled. When enabling Node.js integration
 * in a renderer process, please be aware of potential security implications. You can read
 * more about security risks here:
 *
 * https://electronjs.org/docs/tutorial/security
 *
 * To enable Node.js integration in this file, open up `main.ts` and enable the `nodeIntegration`
 * flag:
 *
 * ```
 *  // Create the browser window.
 *  mainWindow = new BrowserWindow({
 *    width: 800,
 *    height: 600,
 *    webPreferences: {
 *      nodeIntegration: true
 *    }
 *  });
 * ```
 */
import { createApp } from "vue";
import { createRouter, createMemoryHistory } from "vue-router";
import { createPinia } from "pinia";
import App from "./App.vue";
import "./index.css";
import "highlight.js/styles/github-dark-dimmed.min.css";
import { useConversationStore } from "./stores/conversation";

import Home from "./views/Home.vue";
import Conversation from "./views/Conversation.vue";
import Setting from "./views/Setting.vue";

const routes = [
  { path: "/", component: Home },
  { path: "/conversation", component: Conversation },
  { path: "/setting", component: Setting },
];
const pinia = createPinia();
const router = createRouter({
  history: createMemoryHistory(),
  routes,
});

router.beforeEach((to) => {
  if (!to.path.startsWith("/conversation")) {
    const store = useConversationStore();
    store.selectedId = -1;
  }
});
createApp(App).use(router).use(pinia).mount("#app");
console.log(
  '👋 This message is being logged by "renderer.ts", included via Vite'
);
